<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Reads the next frame</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="stomp.hasframe.html">Stomp::hasFrame</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="stomp.send.html">Stomp::send</a></div>
 <div class="up"><a href="class.stomp.html">Stomp</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="stomp.readframe" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Stomp::readFrame</h1>
  <h1 class="refname">stomp_read_frame</h1>
  <p class="verinfo">(PECL stomp &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">Stomp::readFrame</span> -- <span class="refname">stomp_read_frame</span> &mdash; <span class="dc-title">Reads the next frame</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-stomp.readframe-description">
  <h3 class="title">说明</h3>
  <p class="para">面向对象风格 (method):</p>
   <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type"><a href="class.stompframe.html" class="type stompframe">stompframe</a></span> <span class="methodname"><strong>Stomp::readFrame</strong></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$class_name</code><span class="initializer"> = &quot;stompFrame&quot;</span></span>
   ] )</div>

  <p class="para rdfs-comment">过程化风格:</p>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><strong>stomp_read_frame</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$link</code></span>
   )</div>

  <p class="para rdfs-comment">
   Reads the next frame. It is possible to instantiate an object of a specific class, and pass parameters to that class&#039;s constructor. 
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-stomp.readframe-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    <dt>
<em><code class="parameter">link</code></em></dt>
<dd>
<p class="para">仅对过程化样式：由 <span class="function"><a href="stomp.construct.html" class="function">stomp_connect()</a></span> 返回的 stomp 连接标识符。</p></dd>

    
     <dt>
<em><code class="parameter">class_name</code></em></dt>

     <dd>

      <p class="para">
        The name of the class to instantiate. If not specified, a stompFrame object is returned.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-stomp.readframe-returnvalues">
  <h3 class="title">返回值</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">A transaction header may be specified, indicating that the message acknowledgment should be part of the named transaction.</p></p></blockquote>
 </div>


 <div class="refsect1 changelog" id="refsect1-stomp.readframe-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>Stomp 0.4.0</td>
       <td>
        <em><code class="parameter">class_name</code></em> parameter was added.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-stomp.readframe-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4552">
    <p><strong>Example #1 面向对象风格</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">/*&nbsp;connection&nbsp;*/<br /></span><span style="color: #007700">try&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$stomp&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Stomp</span><span style="color: #007700">(</span><span style="color: #DD0000">'tcp://localhost:61613'</span><span style="color: #007700">);<br />}&nbsp;catch(</span><span style="color: #0000BB">StompException&nbsp;$e</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">'Connection&nbsp;failed:&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$e</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getMessage</span><span style="color: #007700">());<br />}<br /><br /></span><span style="color: #FF8000">/*&nbsp;subscribe&nbsp;to&nbsp;messages&nbsp;from&nbsp;the&nbsp;queue&nbsp;'foo'&nbsp;*/<br /></span><span style="color: #0000BB">$stomp</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">subscribe</span><span style="color: #007700">(</span><span style="color: #DD0000">'/queue/foo'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;read&nbsp;a&nbsp;frame&nbsp;*/<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$stomp</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">readFrame</span><span style="color: #007700">());<br /><br /></span><span style="color: #FF8000">/*&nbsp;close&nbsp;connection&nbsp;*/<br /></span><span style="color: #007700">unset(</span><span style="color: #0000BB">$stomp</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

     <div class="example-contents"><p>以上例程的输出类似于：</p></div>
     <div class="example-contents screen">
<div class="cdata"><pre>
object(StompFrame)#2 (3) {
  [&quot;command&quot;]=&gt;
  string(7) &quot;MESSAGE&quot;
  [&quot;headers&quot;]=&gt;
  array(5) {
    [&quot;message-id&quot;]=&gt;
    string(41) &quot;ID:php.net-55293-1257226743606-4:2:-1:1:1&quot;
    [&quot;destination&quot;]=&gt;
    string(10) &quot;/queue/foo&quot;
    [&quot;timestamp&quot;]=&gt;
    string(13) &quot;1257226805828&quot;
    [&quot;expires&quot;]=&gt;
    string(1) &quot;0&quot;
    [&quot;priority&quot;]=&gt;
    string(1) &quot;0&quot;
  }
  [&quot;body&quot;]=&gt;
  string(3) &quot;bar&quot;
}
</pre></div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="example-4553">
    <p><strong>Example #2 过程化风格</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">/*&nbsp;connection&nbsp;*/<br /></span><span style="color: #0000BB">$link&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">stomp_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'ssl://localhost:61612'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;check&nbsp;connection&nbsp;*/<br /></span><span style="color: #007700">if&nbsp;(!</span><span style="color: #0000BB">$link</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">'Connection&nbsp;failed:&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">stomp_connect_error</span><span style="color: #007700">());<br />}<br /><br /></span><span style="color: #FF8000">/*&nbsp;subscribe&nbsp;to&nbsp;messages&nbsp;from&nbsp;the&nbsp;queue&nbsp;'foo'&nbsp;*/<br /></span><span style="color: #0000BB">stomp_subscribe</span><span style="color: #007700">(</span><span style="color: #0000BB">$link</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'/queue/foo'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;read&nbsp;a&nbsp;frame&nbsp;*/<br /></span><span style="color: #0000BB">$frame&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">stomp_read_frame</span><span style="color: #007700">(</span><span style="color: #0000BB">$link</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;close&nbsp;connection&nbsp;*/<br /></span><span style="color: #0000BB">stomp_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$link</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

     <div class="example-contents"><p>以上例程的输出类似于：</p></div>
     <div class="example-contents screen">
<div class="cdata"><pre>
array(3) {
  [&quot;command&quot;]=&gt;
  string(7) &quot;MESSAGE&quot;
  [&quot;body&quot;]=&gt;
  string(3) &quot;bar&quot;
  [&quot;headers&quot;]=&gt;
  array(6) {
    [&quot;transaction&quot;]=&gt;
    string(2) &quot;t1&quot;
    [&quot;message-id&quot;]=&gt;
    string(41) &quot;ID:php.net-55293-1257226743606-4:3:-1:1:1&quot;
    [&quot;destination&quot;]=&gt;
    string(10) &quot;/queue/foo&quot;
    [&quot;timestamp&quot;]=&gt;
    string(13) &quot;1257227037059&quot;
    [&quot;expires&quot;]=&gt;
    string(1) &quot;0&quot;
    [&quot;priority&quot;]=&gt;
    string(1) &quot;0&quot;
  }
}
</pre></div>
    </div>
   </div>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="stomp.hasframe.html">Stomp::hasFrame</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="stomp.send.html">Stomp::send</a></div>
 <div class="up"><a href="class.stomp.html">Stomp</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
